package com.freedom.sql.jdbc.bind;

public class Link implements Comparable<Object> {// 实现Comparable 接口
	private String name;
	private String physicalDB;
	private String physicalTable;
	private int weight;

	public Link(String _name, String _physicalDB, String _physicalTable, int _weight) {
		name = _name;
		physicalDB = _physicalDB;
		physicalTable = _physicalTable;
		weight = _weight;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhysicalDB() {
		return physicalDB;
	}

	public void setPhysicalDB(String physicalDB) {
		this.physicalDB = physicalDB;
	}

	public String getPhysicalTable() {
		return physicalTable;
	}

	public void setPhysicalTable(String physicalTable) {
		this.physicalTable = physicalTable;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	@Override
	public int compareTo(Object o) {
		Link b = (Link) o;
		if (this.weight < b.weight) {
			return 1;
		} else if (this.weight == b.weight) {
			return 0;
		} else {
			return -1;
		}
	}

	public String toString() {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(name + " ");
		sBuilder.append(physicalDB + " ");
		sBuilder.append(physicalTable + " ");
		sBuilder.append(weight + "\n");
		return sBuilder.toString();
	}

}
